<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>采购计划管理</title>
<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/default/easyui.css"/>">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/icon.css"/>">
<link rel="stylesheet" type="text/css" href="<c:url value="/css/themes/yzr_style.css"/>">

<script type="text/javascript" src="<c:url value="/js/jquery.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery.easyui.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/easyui-lang-zh_CN.js"/>"></script>
</head>
<body>
<%-- <script src="<c:url value="/js/jquery-migrate-1.1.0.min.js"/>"></script>
<script type="text/javascript" src="<c:url value="/js/jquery.jqprint-0.3.js"/>"></script> --%>
<style>
	* {
		font-size: 12px;
		padding:0px;
		margin:0px;
	}
</style>
<!-- 添加 -->
<script type="text/javascript">

	var editIndexYzr = undefined;
	
	//添加行
	function appendYzr(){
		if(endEditingYzr()){
			$('#yzr-medPlan-dg').datagrid('appendRow',{'medPurchDets.purchDetMedId': [], 'medPurchDets.purchDetGuige': [], 'medPurchDets.purchDetUnit': [],'medPurchDets.purchDetNumber': [],'medPurchDets.purchDetSupId': [],'medPurchDets.purchDetYijiMoney': []});
			editIndexYzr = $('#yzr-medPlan-dg').datagrid('getRows').length-1;
			$('#yzr-medPlan-dg').datagrid('selectRow',editIndexYzr)
							   .datagrid('beginEdit',editIndexYzr);
		}
		
	}
	//删除行
	function removeitYzr(){
		if(editIndexYzr == undefined){return}
		$('#yzr-medPlan-dg').datagrid('cancelEdit',editIndexYzr)
		   .datagrid('deleteRow',editIndexYzr);
	}
	
	//应用
	function acceptYzr(){
		if(endEditingYzr()){
			endEditingYzr();
		}
	}
	
	//撤销
	function rejectYzr(){
		$('#yzr-medPlan-dg').datagrid('rejectChanges');
		editIndexYzr = undefined;
	}
	
	//获取数据
	function getChangesYzr(){
		var rows = $('#yzr-medPlan-dg').datagrid('getChanges');
		alert(rows.length+' rows are changed!');
	}
	
	
	//结束正在编辑的行
	function endEditingYzr(){
		
		if (editIndexYzr == undefined){return true}
		
		if ($('#yzr-medPlan-dg').datagrid('validateRow', editIndexYzr)){
			
			var ed = $('#yzr-medPlan-dg').datagrid('getEditor', {index:editIndexYzr,field:'medPurchDets.purchDetMedId'});					
			var medName = $(ed.target).combogrid('getText');			
			$('#yzr-medPlan-dg').datagrid('getRows')[editIndexYzr]['medName'] = medName;
			
			
			var ed2 = $('#yzr-medPlan-dg').datagrid('getEditor', {index:editIndexYzr,field:'medPurchDets.purchDetSupId'});					
			var supName = $(ed2.target).combogrid('getText');			
			$('#yzr-medPlan-dg').datagrid('getRows')[editIndexYzr]['supName'] = supName;
			
			
			
			
			$('#yzr-medPlan-dg').datagrid('endEdit', editIndexYzr);
			editIndexYzr = undefined;
			return true;
		} else {
			return false;
		}
	}
	
	//事件：单击单元格的事件
	function onClickCellYzr(index, field){
		if (editIndexYzr != index){
			if (endEditingYzr()){
				
				$('#yzr-medPlan-dg').datagrid('selectRow', index).datagrid('beginEdit', index);
				
				var ed = $('#yzr-medPlan-dg').datagrid('getEditor', {index:index,field:field});
				
				if (ed){
					($(ed.target).data('textbox') ? $(ed.target).textbox('textbox') : $(ed.target)).focus();
				}
				editIndexYzr = index;
			} else {
				setTimeout(function(){
					$('#yzr-medPlan-dg').datagrid('selectRow', editIndexYzr);
				},0);
			}
		}
	}
		
	
	//提交采购计划
	function savePlanYzr(){
		var rows = $('#yzr-medPlan-dg').datagrid('getChanges');
		console.log(JSON.stringify(rows));
		
		
		for(var i = 0; i < rows.length; i ++){
			generateHiddenYzr(rows[i], "MedId", i);
			generateHiddenYzr(rows[i], "Guige", i);
			generateHiddenYzr(rows[i], "Unit", i);
			generateHiddenYzr(rows[i], "Number", i);
			generateHiddenYzr(rows[i], "SupId", i);
			generateHiddenYzr(rows[i], "YijiMoney", i);
		}
		
		var ff_plan = $("#yzr_medPlan_form");
		
		ff_plan.form("submit", {
			success: function(v){
				$.messager.alert('提示', "提交成功");
				$(":hidden[x='y']").remove();
				
				$('#yzr_medPlan_form').form("clear");
				rejectYzr();
				$('#yzr-medPlan-window').window('close');
				$("#tb-medPurchPlan").datagrid("reload"); 
			}
		});
	}
	
	function generateHiddenYzr(row, name, i){
		var ff_plan = $("#yzr_medPlan_form");
		$("<input type='hidden' x='y'>")
			.attr("name", "medPurchDets[" + i + ']' + '.purchDet' + name)
			.val(row['medPurchDets.purchDet' + name])
			.appendTo(ff_plan);
	}
</script>

<!-- 编辑 -->
<script type="text/javascript">

	var editIndex_editPurchPlan = undefined;
	
	//结束编辑行
	function endEditing_editPurchPlan(){
		
		if (editIndex_editPurchPlan == undefined){return true}
		
		if ($('#yzr-editPurchPlan-dg').datagrid('validateRow', editIndex_editPurchPlan)){
			
			//给药品名赋值
			var ed = $('#yzr-editPurchPlan-dg').datagrid('getEditor', {index:editIndex_editPurchPlan,field:'medId'});					
			var medName = $(ed.target).combogrid('getText');			
			$('#yzr-editPurchPlan-dg').datagrid('getRows')[editIndex_editPurchPlan]['medName'] = medName;
			
			//给供应商名赋值
			var ed2 = $('#yzr-editPurchPlan-dg').datagrid('getEditor', {index:editIndex_editPurchPlan,field:'supId'});					
			var supName = $(ed2.target).combogrid('getText');			
			$('#yzr-editPurchPlan-dg').datagrid('getRows')[editIndex_editPurchPlan]['supName'] = supName;
			
			
			
			$('#yzr-editPurchPlan-dg').datagrid('endEdit', editIndex_editPurchPlan);			
			editIndex_editPurchPlan = undefined;
			
			
			return true;
		} else {
			return false;
		}
	}
	
	//单击行
	function onClickRow_editPurchPlan(index, field){
		
		if (editIndex_editPurchPlan != index){
			
			if (endEditing_editPurchPlan()){			
				$('#yzr-editPurchPlan-dg').datagrid('selectRow', index).datagrid('beginEdit', index);								
				editIndex_editPurchPlan = index;
				
			} else {			
				$('#yzr-editPurchPlan-dg').datagrid('selectRow', editIndex_editPurchPlan);
			}
		}
	}

	//添加行
	function append_editPurchPlan(){
		if (endEditing_editPurchPlan()){
			$('#yzr-editPurchPlan-dg').datagrid('appendRow',{
				'purchDetId': [],'medId': [], 
				'purchDetGuige': [], 'purchDetUnit': [],
				'purchDetNumber': [],'supId': [],
				'purchDetYijiMoney': []}); 
			
			
			editIndex_editPurchPlan = $('#yzr-editPurchPlan-dg').datagrid('getRows').length-1;
			$('#yzr-editPurchPlan-dg').datagrid('selectRow', editIndex_editPurchPlan)
					.datagrid('beginEdit', editIndex_editPurchPlan);
		}
	}
	
	//移除一行
	function removeit_editPurchPlan(){
		
		if (editIndex_editPurchPlan == undefined){return}
		
		$('#yzr-editPurchPlan-dg').datagrid('cancelEdit', editIndex_editPurchPlan)
				.datagrid('deleteRow', editIndex_editPurchPlan);
		
		editIndex_editPurchPlan = undefined;
	}

	
	//应用
	function accept_editPurchPlan(){
		if (endEditing_editPurchPlan()){
			$('#yzr-editPurchPlan-dg').datagrid('acceptChanges');
		}
	}
	
	
	//撤销
	function reject_editPurchPlan(){
		$('#yzr-editPurchPlan-dg').datagrid('rejectChanges');
		editIndex_editPurchPlan = undefined;
	}
	
	//提交采购计划
	function saveEditPurchPlanYzr(){
		
		var rows = $('#yzr-editPurchPlan-dg').datagrid('getRows');		
		console.log(JSON.stringify(rows));
		
		for(var i = 0; i < rows.length; i ++){
			generateHiddenYzr_edit(rows[i], "medId", i);
			generateHiddenYzr_edit(rows[i], "medName", i);
			generateHiddenYzr_edit(rows[i], "purchDetId", i);
			generateHiddenYzr_edit(rows[i], "purchDetPurchId", i);
			generateHiddenYzr_edit(rows[i], "purchDetGuige", i);
			generateHiddenYzr_edit(rows[i], "purchDetUnit", i);
			generateHiddenYzr_edit(rows[i], "purchDetNumber", i);
			generateHiddenYzr_edit(rows[i], "supId", i);
			generateHiddenYzr_edit(rows[i], "purchDetYijiMoney", i);
		}
		
		var ff_plan = $("#yzr_editPurchPlan_form");
		
		ff_plan.form("submit", {
			url: 'editPurchPlan',
			onSubmit: function(){
		    	return $(this).form("validate");
		    },
			success: function(v){
				$.messager.alert('提示', "提交成功");
				$(":hidden[x='y']").remove();			
				$('#yzr_editPurchPlan_form').form("clear");
				reject_editPurchPlan();
				$('#yzr-editPurchPlan-window').window('close');
				$("#tb-medPurchPlan").datagrid("reload");
			}
		});
	}
	
	
	//name=medPurchDets[0] .属性名称
	//value = row[属性名称]
	//创建隐式表单域来保存明细
	function generateHiddenYzr_edit(row, name, i){
		var ff_plan = $("#yzr_editPurchPlan_form");
		$("<input type='hidden' x='y'>")
			.attr("name", "medPurchDets[" + i + '].'  + name)
			.val(row[name])
			.appendTo(ff_plan);
	}
	

</script>

<!-- 打印 -->
<script type="text/javascript">
	$(function(){
		//获取当前登录用户的id
		var  planZdr_staffId = $("#tontyiStaffId").html();
		
		
		//打开添加采购计划窗口
		$("#yzr-medPurchPlan-add").linkbutton({onClick: function(){
			$('#yzr_medPlan_form').form("clear");
			rejectYzr();
			$(":hidden[x='y']").remove();
			$('#yzr-medPlan-window').window("open");			
			//自动填写制定人
			$("#yzr-medPlan-mkp").combogrid("setValue",planZdr_staffId);
		}});
		
		//日期转换
		function yzr_todate(value){
            var date = new Date(value);  
            return date.toLocaleDateString();
        }
		
		//查看计划明细-打印
		$("#yzr-medPurchPlan-edit").linkbutton({onClick: function(){
			var rows = $("#tb-medPurchPlan").datagrid("getSelections");
			if(rows.length == 1){
				$('#yzr-purchDet-window').window({'title': "打印采购计划"});
				$('#yzr-purchDet-window').window("open");
				$('#yzr-purchDet-print-hidden').css("display","inline");
				$('#yzr-purchDet-print-hidden').show();
				var purchId = rows[0].purchId;
				
				$.getJSON("queryMedPurchById", {"purchId": purchId}, function(data){
					$("#yzr-purchDet-cgbh").linkbutton({text: data.purchId});
					$("#yzr-purchDet-xmmc").linkbutton({text: data.purchTitle});
					$("#yzr-purchDet-zdr").linkbutton({text: data.staffName});
					$("#yzr-purchDet-zdsj").linkbutton({text: yzr_todate(data.purchZdTime)});
					$("#yzr-purchDet-spr").linkbutton({text: data.staffNameSp});
					$("#yzr-purchDet-spzt").linkbutton({text: data.purchAutditState});
					if(data.purchAutditState=='待审核' || data.purchAutditState=='未通过'){
						$("#yzr-purchDet-spzt").css({'color': 'red'});
					}
					if(data.purchAutditState=='已通过'){
						$("#yzr-purchDet-spzt").css({'color': 'green'});
					}
					
					if(yzr_todate(data.purchAutditTime)=='1970/1/1'){
						data.purchAutditTime = '';
					}
					$("#yzr-purchDet-spsj").linkbutton({text: data.purchAutditTime});
					$("#yzr-purchDet-cgzt").linkbutton({text: data.purchState});
					if(data.purchState=='未采购'){
						$("#yzr-purchDet-cgzt").css({'color': 'red'});
					}
				});	
				
				 //根据id查看详情	
				 $("#yzr-purchDet-dg").datagrid({
					url:'queryAllPurchDet',
					width: '100%',
					queryParams:{
						page:1, 
		    			rows:100,
						purchId: purchId
					}
				});
			}else{
				$.messager.alert("提示", "只能选择一条记录，您目前选择了" + rows.length + "条!");
			}
		}});
		
		//打印
		/* function printdivYzr(printpage){ 
			//获得当前页面body里面的内容
			var bodyHtml = document.body.innerHTML;
			//把打印的内容填充
			document.body.innerHTML = printpage; 
			//打印
			window.print(); 
			//把body的内容还原
			document.body.innerHTML = bodyHtml; 
			return true;

		} */
		//点击按钮打印
		/* $("#yzr-purchDet-print").linkbutton({
			onClick: function(){ */
				
				/* var printpage = $('#yzr-purchDet-printArea').html();
				printdivYzr(printpage); */
	/* 			
				$("#yzr_purchDet_form").jqprint();
			}
		}); */
		
		
		
		//显示全部
		$("#yzr-medPurchPlan-reload").linkbutton({onClick:function(){
			$("#tb-medPurchPlan").datagrid({
	    		url: 'queryAllMedPurch', 
	    		method: 'get'
	    	});			
		}});
		
		//根据状态查找采购计划
		$("#yzr-medPurchPlan-dsp").linkbutton({onClick:function(){
			$("#tb-medPurchPlan").datagrid({
	    		url: 'queryByAutditState', 
	    		method: 'get',
	    		queryParams:{					
	    			state: '待审核',
					page:1, 
	    			rows:16
				}
	    	});
		}});
		
		$("#yzr-medPurchPlan-ysp").linkbutton({onClick:function(){
			$("#tb-medPurchPlan").datagrid({
	    		url: 'queryByAutditState', 
	    		method: 'get',
	    		queryParams:{					
	    			state: '已通过',
					page:1, 
	    			rows:16
				}
	    	});
		}});
		
		
		
		//根据条件搜索
		$('#yzr-medPurchPlan-search').searchbox({
		    searcher:function(value,name){
		    	if(value == ''){
		    		$.messager.alert("提示", "请输入查询条件！");
		    	}else{
		    		$("#tb-medPurchPlan").datagrid({	    		
			    		url: name == 'name' ? 'queryByTitle' : 'queryByPurchState',
			    		method: 'post', 
			    		queryParams: {
			    			shuxing: value
			    	}});
		    		$('#yzr-medPurchPlan-search').searchbox('setValue', '');
		    	}		    	
		    }
		
		}); 
		
		/* 查看详情 */
		$("#yzr-medPurchPlan-more").linkbutton({onClick: function(){
			var rows = $("#tb-medPurchPlan").datagrid("getSelections");
			if(rows.length == 1){
				var purchId = rows[0].purchId;
				$('#yzr-purchDet-window').window({'title': "采购计划详情"});
				$('#yzr-purchDet-window').window("open");
				$('#yzr-purchDet-print-hidden').css("display","none");
				
				$.getJSON("queryMedPurchById", {"purchId": purchId}, function(data){
					$("#yzr-purchDet-cgbh").linkbutton({text: data.purchId});
					$("#yzr-purchDet-xmmc").linkbutton({text: data.purchTitle});
					$("#yzr-purchDet-zdr").linkbutton({text: data.staffName});
					$("#yzr-purchDet-zdsj").linkbutton({text: yzr_todate(data.purchZdTime)});
					$("#yzr-purchDet-spr").linkbutton({text: data.staffNameSp});
					$("#yzr-purchDet-spzt").linkbutton({text: data.purchAutditState});
					if(data.purchAutditState=='待审核' || data.purchAutditState=='未通过'){
						$("#yzr-purchDet-spzt").css({'color': 'red'});
					}
					if(data.purchAutditState=='已通过'){
						$("#yzr-purchDet-spzt").css({'color': 'green'});
					}
					
					if(yzr_todate(data.purchAutditTime)=='1970/1/1'){
						data.purchAutditTime = '';
					}
					$("#yzr-purchDet-spsj").linkbutton({text: data.purchAutditTime});
					$("#yzr-purchDet-cgzt").linkbutton({text: data.purchState});
					if(data.purchState=='未采购'){
						$("#yzr-purchDet-cgzt").css({'color': 'red'});
					}
				});	
				
				 //根据id查看详情	
				 $("#yzr-purchDet-dg").datagrid({
					url:'queryAllPurchDet',
					width: '100%',
					queryParams:{
						page:1, 
		    			rows:16,
						purchId: purchId
					}
				});
			}else{
				$.messager.alert("提示", "请选择一条记录!");
			}
			
		}});
		
		//打开编辑采购计划窗口
		$("#yzr-medPurchPlan-detail").linkbutton({onClick: function(){
			var rows = $("#tb-medPurchPlan").datagrid("getSelections");
			
			var purchState = rows[0].purchState;
			var purchId = rows[0].purchId;
			var mkpId = rows[0].purchMakepeople
			
			if(purchState == '已采购'){
				$.messager.confirm("提示", "不能修改已经采购的采购计划!<br><br>是否查看详情？", function(data){
					if (data) {  
		                $('#yzr-purchDet-window').window({'title': "采购计划详情"});
						$('#yzr-purchDet-window').window("open");
						$('#yzr-purchDet-print-hidden').css("display","none");
						
						$.getJSON("queryMedPurchById", {"purchId": purchId}, function(data){
							$("#yzr-purchDet-cgbh").linkbutton({text: data.purchId});
							$("#yzr-purchDet-xmmc").linkbutton({text: data.purchTitle});
							$("#yzr-purchDet-zdr").linkbutton({text: data.staffName});
							$("#yzr-purchDet-zdsj").linkbutton({text: yzr_todate(data.purchZdTime)});
							$("#yzr-purchDet-spr").linkbutton({text: data.staffNameSp});
							$("#yzr-purchDet-spzt").linkbutton({text: data.purchAutditState});
							if(data.purchAutditState=='待审核' || data.purchAutditState=='未通过'){
								$("#yzr-purchDet-spzt").css({'color': 'red'});
							}
							if(data.purchAutditState=='已通过'){
								$("#yzr-purchDet-spzt").css({'color': 'green'});
							}
							
							if(yzr_todate(data.purchAutditTime)=='1970/1/1'){
								data.purchAutditTime = '';
							}
							$("#yzr-purchDet-spsj").linkbutton({text: data.purchAutditTime});
							$("#yzr-purchDet-cgzt").linkbutton({text: data.purchState});
							if(data.purchState=='未采购'){
								$("#yzr-purchDet-cgzt").css({'color': 'red'});
							}
						});	
						
						 //根据id查看详情	
						 $("#yzr-purchDet-dg").datagrid({
							url:'queryAllPurchDet',
							width: '100%',
							queryParams:{
								page:1, 
				    			rows:100,
								purchId: purchId
							}
						});
		            }  
		            else {  
		            	
		            }
				});				
									
						 
			}else{
				if(planZdr_staffId == mkpId){
					if(rows.length == 1){
						$('#yzr-editPurchPlan-window').window({'title': "编辑采购计划"});
						$('#yzr-editPurchPlan-window').window("open");
						//var purchId = rows[0].purchId;
						
						$.getJSON("queryMedPurchById", {"purchId": purchId}, function(data){
							$("#yzr-editPurchPlan-id").textbox("setValue",data.purchId);
							$("#yzr-editPurchPlan-title").textbox("setValue",data.purchTitle);
							$("#yzr-editPurchPlan-mkp").combogrid("setValue",data.purchMakepeople);
							$("#yzr-editPurchPlan-zdrq").datebox("setValue", yzr_todate(data.purchZdTime));//制定日期
							$("#yzr-editPurchPlan-spr").combogrid("setValue",  data.purchAutdit);					
							$("#yzr-editPurchPlan-dhrq").datebox("setValue",  yzr_todate(data.purchArriivalDate));//预计到货日期 				
						});	
						
						 //根据id查看详情	
						 $("#yzr-editPurchPlan-dg").datagrid({
							url:'queryAllPurchDet2',
							queryParams:{
								purchId: purchId
							}
						});
					}else{
						$.messager.alert("提示", "请选择一条记录!");
					}
				}else{
					$.messager.alert("提示", "只能修改自己的记录!");
				}				
			}			
		}});
		
		
		
		//关闭编辑窗口，刷新
		$("#yzr-editPurchPlan-close").linkbutton({onClick: function(){
			$(":hidden[x='y']").remove();			
			$('#yzr_editPurchPlan_form').form("clear");
			reject_editPurchPlan();
			$('#yzr-editPurchPlan-window').window('close');
			$("#tb-medPurchPlan").datagrid("reload");
		}});
		
		
	});
</script>




	<!-- 显示所有计划 -->
	<table id="tb-medPurchPlan" class="easyui-datagrid" 
		data-options="
			url:'queryAllMedPurch',
			singleSelect: true,
			fitColumns:true,
			fit:true,
			striped:true,
			pagination: true,
			pageSize: 16,
			pageList: [16, 32, 48, 54],
			rownumbers: true,
			toolbar: '#yzr-medPurchPlan-tb',
			border:false
			">
		<thead>
			<tr>	
				<th data-options="field:'purchId',width:'10%',checkbox:true,align:'center'">计划编号</th>				
				<th data-options="field:'purchTitle',width:'20%',align:'center'">项目名称</th>
				<th data-options="field:'staffName',width:'8%',align:'center'">制定人</th>
				<th data-options="field:'purchMakepeople',width:'8%',align:'center',hidden:true">制定人</th>
				<th data-options="field:'staffNameSp',width:'8%',align:'center'">审批人</th>
				
				<th data-options="field:'purchZdTime',width:'13%',align:'center'">制定时间</th>
				
				<th data-options="field:'purchAutditState',width:'10%',align:'center'">审批状态</th>
				
				<th data-options="field:'purchArriivalDate',width:'13%',align:'center'">预计到货时间</th>
				<th data-options="field:'purchState',width:'11%',align:'center',
											styler: function(value,row,index){ 
	                                        if(row.purchState == '已采购'){ 
	                                            return 'color:green;'; 
	                                        }else{
	                                        	return 'color:red;';
	                                        }
	                                        }">采购状态</th>
				<th data-options="field:'purchRemark',width:'16%',align:'center'">备注</th>
			</tr>
		</thead>
	</table>
	
	<!-- 工具栏 -->
	<div id="yzr-medPurchPlan-tb">
		<a id="yzr-medPurchPlan-add" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加计划</a>			
		<a id="yzr-medPurchPlan-detail" class="easyui-linkbutton" data-options="iconCls:'icon-edit',plain:true">修改计划</a>
		<a id="yzr-medPurchPlan-more" class="easyui-linkbutton" data-options="iconCls:'icon-more',plain:true">查看详情</a>			
		<a id="yzr-medPurchPlan-edit" class="easyui-linkbutton" data-options="iconCls:'icon-print',plain:true">打印计划</a>
		<!-- <a id="yzr-medPurchPlan-myplan" class="easyui-linkbutton" data-options="iconCls:'icon-my',plain:true">我的计划</a> -->
		<a id="yzr-medPurchPlan-dsp" class="easyui-linkbutton" data-options="iconCls:'icon-dsp',plain:true">待审批</a>	
		<a id="yzr-medPurchPlan-ysp" class="easyui-linkbutton" data-options="iconCls:'icon-ysp',plain:true">已审批</a>					
		<a id="yzr-medPurchPlan-reload" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true">刷新</a>				
		<input id="yzr-medPurchPlan-search" class="easyui-searchbox" data-options="menu: '#yzr-medPurchPlan-pName', width: '25%', prompt: '请输入关键字'"/>
	</div>
	
	<!-- 搜索栏 -->
	<div id="yzr-medPurchPlan-pName" style="width:15%;">
	    <div data-options="name:'name'">项目名称</div>
	     <div data-options="name:'state'">采购状态</div>
	</div>
	
	
	<!--查看详情窗口-打印 -->
	<div id="yzr-purchDet-window" class="easyui-window" title="打印采购详情" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:70%;height:70%;">		
		<div class="easyui-layout" style="padding:0px;" data-options="fit:true">			
			<div id="yzr-purchDet-printArea" data-options="region:'center'" style="padding:5px;border-top:none;border-left:none;border-right:none;">	
				
				<form id="yzr_purchDet_form" method="post" style="margin:10px;width:98%;">
					<table width="98%" style="margin:10px;">
						<tr>
							<td>采购计划编号:<a id="yzr-purchDet-cgbh" name="purchId" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>项目名称:<a id="yzr-purchDet-xmmc" name="purchTitle" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>制定人:<a id="yzr-purchDet-zdr" name="staffName" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>制定时间:<a id="yzr-purchDet-zdsj" name="purchZdTime" class="easyui-linkbutton" data-options="plain:true"></a></td>
						</tr>
						<tr>
							<td>审批人:<a id="yzr-purchDet-spr" name="staffNameSp" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>审批状态:<a id="yzr-purchDet-spzt" name="purchAutditState" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>审批时间:<a id="yzr-purchDet-spsj" name="purchAutditTime" class="easyui-linkbutton" data-options="plain:true"></a></td>
							<td>采购状态:<a id="yzr-purchDet-cgzt" name="purchState" class="easyui-linkbutton" data-options="plain:true"></a></td>
						</tr>
					</table>
						
					<div style="margin: 10px;">
						<div id="yzr-purchDet-tabs" class="easyui-tabs" style="width:98%; margin-top:10px;" 
							data-options="plain:true,narrow:true">
							
							<div title="采购计划明细" style="padding:10px;">
								<table id="yzr-purchDet-dg" class="easyui-datagrid"  style="margin-left:10px"
										data-options="
											iconCls: 'icon-edit',
											singleSelect: true,
											align: 'center',										
											width: '98%'
											">
										<thead>
											<tr>	
												<th data-options="field:'purchDetId',width:'20%',align:'center'">计划明细编号</th>	
												<!-- <th data-options="field:'medId',width:'16%',align:'center'">药品编号</th>	 -->		
												<th data-options="field:'medName',width:'20%',align:'center'">药品名称</th>
												<th data-options="field:'purchDetGuige',width:'8%',align:'center'">规格</th>
												<th data-options="field:'purchDetUnit',width:'8%',align:'center'">单位</th>
												<th data-options="field:'purchDetNumber',width:'8%',align:'center'">数量</th>
												<th data-options="field:'supName',width:'29%',align:'center'">供应商</th>
												<th data-options="field:'purchDetYijiMoney',width:'8%',align:'center'">预计金额</th>
											</tr>
										</thead>
								 </table>
							</div>						
						</div>				
					</div>
				</form>
				
								
			</div>
					
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<div id="yzr-purchDet-print-hidden" style="display:inline;"><a id="yzr-purchDet-print" class="easyui-linkbutton" data-options="iconCls:'icon-print', plain:true">打印</a></div>
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:$('#yzr-purchDet-window').window('close');" onclick="">取消</a>
			</div>			
		</div>
	</div>
		
	
	<!--新增采购计划窗口 -->
	<div id="yzr-medPlan-window" class="easyui-window" title="新增采购计划" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:80%;height:70%;">		
		<div class="easyui-layout" style="padding:0px;" data-options="fit:true">			
			<div data-options="region:'center'" style="padding:5px;border-top:none;border-left:none;border-right:none;">			
				<form id="yzr_medPlan_form" action="doMedPlan" method="get">
					<table width="98%" style="margin-left:10px;">
						<tr>
							<td width="50%">
								<input class="easyui-textbox"  name="medPurch.purchTitle" id="yzr-medPlan-title" data-options="required:true,label: '项目名称',width:'60%'"/>
							</td>
							<td  width="50%">
								<select class="easyui-combogrid" id="yzr-medPlan-mkp" name="medPurch.purchMakepeople"
									data-options="
										label: '制定人',
										readonly:true,
										width: '60%',
										panelWidth: '290',
										panelHeight: 'auto',
										required:true,
										url: 'queryAllStaff',
										pagination: true,
										pageSize: 8,
										pageList: [8, 16, 24, 32],
										idField: 'staffNo',
										textField: 'staffName',
										columns: [[
											{field:'staffName',title:'姓名',width:100},
											{field:'departmentName',title:'部门',width:100},
											{field:'postName',title:'职务',width:85}
										]]
									"></select>
							</td>
						</tr>
						<tr>
							<td>
								<select class="easyui-combogrid" id="yzr-medPlan-spr" name="medPurch.purchAutdit"
									data-options="
										label: '审批人',
										width: '60%',
										required:true,
										panelWidth: '290',
										panelHeight: 'auto',
										url: 'queryAllStaff2Yzr',
										pagination: true,
										pageSize: 8,
										pageList: [8, 16, 24, 32],
										idField: 'staffNo',
										textField: 'staffName',
										columns: [[
											{field:'staffName',title:'姓名',width:100},
											{field:'departmentName',title:'部门',width:100},
											{field:'postName',title:'职务',width:85}
										]]
									"></select>
							</td>
							<td>
								<input class="easyui-datebox" name="medPurch.purchArriivalDate" id="yzr-medPlan-dhrq"
									data-options="label:'预计到货日期',width:'60%'">
							</td>
						</tr>
					</table>
				
			
					<div style="margin: 5px;">
						<div id="yzr-medPlan-tabs" class="easyui-tabs" style="width:98%; margin-top:10px;" 
							data-options="plain:true,narrow:true">
							
							<div title="采购计划明细" style="padding:10px">
								<table id="yzr-medPlan-dg" class="easyui-datagrid" style="height:auto;"
										data-options="
											iconCls: 'icon-edit',
											singleSelect: true,
											toolbar: '#yzr-medPlan-tb',
											method: 'get',
											onClickCell: onClickCellYzr,									
											width: '98%'
										">
									<thead>
										<tr>		
											<th data-options="field:'medPurchDets.purchDetMedId',align:'center',width:'25%',
												formatter:function(value,row){
													return row.medName;
												},
												editor:{
													type:'combogrid',
													options:{
														required:true,						
														url: 'queryAllMedicine',
														pagination: true,
														pageSize: 8,
														pageList: [8, 16, 24, 32],
														idField: 'medId',
														textField: 'medName',
														panelWidth: '290',
														panelHeight: 'auto',
														columns: [[
															{field:'medId',title:'药品编号',width:120},
															{field:'medName',title:'药品名称',width:105},
															{field:'medKind',title:'类型',width:60}
														]]										
													}
												}">药品名</th>
												<th data-options="field:'medPurchDets.purchDetGuige',required:true,align:'center',width:'15%',editor:{type:'textbox',options:{required:true}}">规格</th>
												<th data-options="field:'medPurchDets.purchDetUnit',required:true,align:'center',width:'11%',editor:{
														type: 'combobox',
														options:{
															required:true,															
															valueField: 'label',
															textField: 'value',
															panelHeight: 'auto',
															data: [{label:'箱',value:'箱'},
																	{label:'盒',value:'盒'},
																	{label:'瓶',value:'瓶'},
																	{label:'袋',value:'袋'},
																	{label:'片',value:'片'},
																	{label:'支',value:'支'},
																	{label:'板',value:'板'}
																]
														}
												}">单位</th>
												
												<th data-options="field:'medPurchDets.purchDetNumber',width:'10%',align:'center',editor:{type:'numberbox',options:{required:true}}">数量</th>
											
												<th data-options="field:'medPurchDets.purchDetSupId',align:'center',width:'25%',
														formatter:function(value,row){
															return row.supName;
														},
														editor:{
															type: 'combogrid',								
															options:{
																url: 'queryAllSupplier2',
																required:true,
																
																pagination: true,
																pageSize: 8,
																pageList: [8, 16, 24, 32],
																idField: 'supId',
																textField: 'supName',
																panelWidth: '320',
																panelHeight: 'auto',
																columns: [[
																	{field:'supId',title:'供应商编号',width:120},
																	{field:'supName',title:'供应商名称',width:135},
																	{field:'supKind',title:'类型',width:60}
																]]										
														}
													}">供应商</th>
											
												<th data-options="field:'medPurchDets.purchDetYijiMoney',width:'16%',align:'center',editor:{type: 'numberbox',options:{precision:2,required:true}}">预计金额</th>
										</tr>
									</thead>							
								</table>
								
								<!-- 工具栏 -->
								<div id="yzr-medPlan-tb" style="height:auto">
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="appendYzr()">添加一行</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeitYzr()">移除一行</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-ok',plain:true" onclick="acceptYzr()">应用</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="rejectYzr()">撤销</a>
								</div>
							</div>
							
						</div>
						
						
					</div>
				</form>				
			</div>
					
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true, onClick: savePlanYzr">提交</a>				
				<a class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" href="javascript:$('#yzr-medPlan-window').window('close');" onclick="">取消</a>
			</div>			
		</div>
	</div>
		
		
	<!--修改窗口-->
	<div id="yzr-editPurchPlan-window" class="easyui-window" title="修改采购计划" data-options="collapsible:false,minimizable:false,maximizable:false,modal:true,iconCls:'icon-save',closed: true" style="width:70%;height:70%;">		
		<div class="easyui-layout" style="padding:0px;" data-options="fit:true">						
			<div data-options="region:'center'" style="padding:5px;border-top:none;border-left:none;border-right:none;">				
				<form id="yzr_editPurchPlan_form" method="get">
				
					<table width="98%" style="margin-left:10px">
						<tr>
							<td width="33%">
								<input class="easyui-textbox" readonly name="purchId" id="yzr-editPurchPlan-id" data-options="label: '计划单号',width:'90%'"/>
							</td>
							<td width="33%">
								<input class="easyui-textbox" name="purchTitle" id="yzr-editPurchPlan-title" data-options="required:true,label: '项目名称',width:'90%'"/>
							</td>
							<td  width="33%">
								<select class="easyui-combogrid" id="yzr-editPurchPlan-mkp" name="purchMakepeople"
									data-options="
										label: '制定人',
										width: '80%',
										required:true,
										panelWidth: '290',
										panelHeight: 'auto',
										url: 'queryAllStaff',
										pagination: true,
										pageSize: 8,
										pageList: [8, 16, 24, 32],
										idField: 'staffNo',
										textField: 'staffName',
										columns: [[
											{field:'staffName',title:'姓名',width:100},
											{field:'departmentName',title:'部门',width:100},
											{field:'postName',title:'职务',width:85}
										]]
									"></select>
							</td>
						</tr>
						<tr>
							<td>
								<select class="easyui-combogrid" id="yzr-editPurchPlan-spr" name="purchAutdit"
									data-options="
										label: '审批人',
										width: '80%',
										required:true,
										panelWidth: '290',
										panelHeight: 'auto',
										url: 'queryAllStaff',
										pagination: true,
										pageSize: 8,
										pageList: [8, 16, 24, 32],
										idField: 'staffNo',
										textField: 'staffName',
										columns: [[
											{field:'staffName',title:'姓名',width:100},
											{field:'departmentName',title:'部门',width:100},
											{field:'postName',title:'职务',width:85}
										]]
									"></select>
							</td>
							<td>
								<input class="easyui-datebox" name="purchArriivalDate" id="yzr-editPurchPlan-dhrq"
									data-options="label:'预计到货日期',width:'80%'">
							</td>
							<td>
								<input class="easyui-datebox" name="purchZdTime" id="yzr-editPurchPlan-zdrq"
									data-options="label:'制定日期',width:'80%'">
							</td>
						</tr>
					</table>
						
						
					<div style="margin: 5px;">
						<div id="yzr-editPurchPlan-tabs" class="easyui-tabs" style="width:98%; margin-top:10px;" data-options="plain:true,narrow:true">							
							<div title="采购计划明细" style="padding:10px;">
								<table id="yzr-editPurchPlan-dg" class="easyui-datagrid" 
										data-options="
											iconCls: 'icon-edit',
											singleSelect: true,		
											toolbar: '#yzr-editPurchPlan-tb',	
											onClickRow: onClickRow_editPurchPlan,												
											width: '98%'
											">
										<thead>
											<tr>	
												<th data-options="field:'purchDetId',width:'20%',align:'center'">计划明细编号</th>	
												<th data-options="field:'medId',width:'20%',align:'center',
														formatter:function(value,row){
															return row.medName;
														},
														editor:{
															type:'combogrid',
															options:{
																required:true,
																url: 'queryAllMedicine',
																pagination: true,
																pageSize: 8,
																pageList: [8, 16, 24, 32],
																idField: 'medId',
																textField: 'medName',
																panelWidth: '290',
																panelHeight: 'auto',
																columns: [[
																	{field:'medId',title:'药品编号',width:120},
																	{field:'medName',title:'药品名称',width:105},
																	{field:'medKind',title:'类型',width:60}
																]]										
															}
												}">药品名称</th>
												<th data-options="field:'purchDetGuige',width:'10%',align:'center',editor:{type:'textbox',options:{required:true}}">规格</th>
												<th data-options="field:'purchDetUnit',width:'10%',align:'center',editor:{
													type: 'combobox',
													options:{
														required:true,
														valueField: 'label',
														textField: 'value',
														panelHeight: 'auto',
														data: [{label:'箱',value:'箱'},
																{label:'盒',value:'盒'},
																{label:'瓶',value:'瓶'},
																{label:'袋',value:'袋'},
																{label:'片',value:'片'},
																{label:'支',value:'支'},
																{label:'板',value:'板'}
															]
													}
												}">单位</th>
												<th data-options="field:'purchDetNumber',width:'10%',align:'center',editor:{type:'numberbox',options:{required:true}}">数量</th>
												<th data-options="field:'supId',width:'20%',align:'center',
														formatter:function(value,row){
															return row.supName;
														},
														editor:{
															type: 'combogrid',								
															options:{
																url: 'queryAllSupplier',
																required:true,
																pagination: true,
																pageSize: 8,
																pageList: [8, 16, 24, 32],
																idField: 'supId',
																textField: 'supName',
																panelWidth: '290',
																panelHeight: 'auto',
																columns: [[
																	{field:'supId',title:'供应商编号',width:120},
																	{field:'supName',title:'供应商名称',width:105},
																	{field:'supKind',title:'类型',width:60}
																]]										
														}
													}">供应商</th>
												<th data-options="field:'purchDetYijiMoney',width:'11%',align:'center',editor:{type: 'numberbox',options:{precision:2,required:true}}">预计金额</th>
											</tr>
										</thead>
								 </table>
								 
								 <div id="yzr-editPurchPlan-tb" style="height:auto">
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="append_editPurchPlan()">添加</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit_editPurchPlan()">删除</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-save',plain:true" onclick="accept_editPurchPlan()">应用</a>
									<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-undo',plain:true" onclick="reject_editPurchPlan()">撤销</a>
								</div>
							</div>							
						</div>						
					</div>
				</form>				
			</div>					
					
			<div data-options="region:'south',border:false" style="text-align:right;padding:5px 0 0;">
				<a class="easyui-linkbutton" data-options="iconCls:'icon-ok', plain:true, onClick: saveEditPurchPlanYzr">保存</a>
				<a id="yzr-editPurchPlan-close" class="easyui-linkbutton" data-options="iconCls:'icon-cancel', plain:true" >取消</a>
			</div>						
		</div>
	</div>


</body>
</html>